package com.cloud_sang.fubai.controller;

import com.cloud_sang.entity.CommonResult;
import com.cloud_sang.entity.Payment;
import com.cloud_sang.fubai.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassTitle: OrderFeignController
 * @ProjectName springcould2020
 * @Description:
 * @Author Sangsang
 * @Date 2020/9/9
 * @Time 18:05
 */
@RestController
@Slf4j
@RequestMapping("consumer")
public class OrderFeignController {

	private final Logger logger = LoggerFactory.getLogger(getClass());

	@Resource
	private PaymentFeignService paymentFeignService;
	@GetMapping("/payment/get/{id}")
	public CommonResult<Payment> getPayment(@PathVariable("id") Long id){
		//http://localhost:80/consumer/payment/get/{id}?id=1
		return paymentFeignService.getById(id);
	}

	@GetMapping("/feign/timeout")
	public String paymentFeignTimeOut(){
		//openfeign组件 客户端默认等待1s，在业务层有着三秒的延时 需要开启配置
		return paymentFeignService.paymentFeignTimeOut();
	}

}
